cxenstored: fix systemd socket activation
authorWei Liu <wei.liu2@citrix.com>
Mon, 10 Aug 2015 08:00:16 +0000 (09:00 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 13 Aug 2015 09:23:58 +0000 (10:23 +0100)
commit81d758afca7c3c1e3ccbd78154b33d64fd7757fb
tree7075301a1b5e83850ba09f08fd266523128fdfc0
parent145a8004a7d659668d5a3b0ad9868d7678b24822
cxenstored: fix systemd socket activation

There were two problems with original code:

1. sd_booted() was used to determined if the process was started by
   systemd, which was wrong.
2. Exit with error if pidfile was specified, which was too harsh.

These two combined made cxenstored unable to start by hand if it ran
on a system which had systemd.

Fix issues with following changes:

1. Use sd_listen_fds to determine if the process is started by systemd.
2. Don't exit if pidfile is specified.

Rename function and restructure code to make things clearer.

A side effect of this patch is that gcc 4.8 with -Wmaybe-uninitialized
in non-debug build spits out spurious warning about sock and ro_sock
might be uninitialized. Since CentOS 7 ships gcc 4.8, we need to work
around that by setting sock and ro_sock to NULL at the beginning of
main.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/xenstore/xenstored_core.c